<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title><!DOCTYPE html>
        <html>
        <head lang="en">
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
            <title>注册</title>
            <link href="__PUBLIC__/css/register.css" rel="stylesheet" type="text/css">
            <script type="text/javascript" src="__PUBLIC__/js/jquery-1.12.1.js"></script>
        </head>
<body>
<div class="All">
    <div class="content">
        <div class="menu">
            <div class="title">Register</div>
            <div class="user">
                <div class="username">
                    <img src="__PUBLIC__/images/user.png">
                </div>
                <div class="null">
                    <input type="text">
                </div>
            </div>
            <div class="pass">
                <div class="password">
                    <img src="__PUBLIC__/images/lock.png">
                </div>
                <div class="nulll">
                    <input type="password">
                </div>
            </div>
            <div class="pass">
                <div class="telp">
                    <img src="__PUBLIC__/images/tel.png">
                </div>
                <div class="nulll">
                    <input type="tel">
                </div>
                <div class="number" id="Time" onclick="timeCount(this)">获取验证码</div>
            </div>
        </div>
        <div class="Button">
            <div class="btn2">
                注册
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script>
    var clock = "";
    var nums = 10;
    var btn;
    function timeCount(thisbtn)
    {
        btn =thisbtn ;
        btn.disabled = true; //将按钮置为不可点击
        document.getElementById("Time").innerHTML = nums+'秒后重新获取';
        document.getElementById("Time").style.background="#bbbaba";
        document.getElementById("Time").style.background="rgba(0, 0, 0, 0)";
        clock = setInterval(doLoop, 1000); //一秒执行一次
    }
    function doLoop()
    {
        nums--;
        if(nums >= 0){
            document.getElementById("Time").innerHTML= nums+'秒后重新获取';
        }else{
            clearInterval(clock); //清除js定时器
            btn.disabled = false;
            document.getElementById("Time").innerHTML = "获取验证码";
            nums = 10; //重置时间
            document.getElementById("Time").style.background="#000000";
            document.getElementById("Time").style.background="rgba(0, 0, 0, 0)";
        }
    }
    $(function(){
        $(".btn2").click(function(){
            $.post("{:U('register2')}",
                    {
                        name:$(".null input").val(),
                        password:$(".nulll input").val()
                    },
                    function(data,status){
                        if(data=="sucess"){
                            var href="{:U('register3',array('news'=>'sucess'))}";
                            href = href.replace("sucess",data);
                            window.location.href=href;
                        }else{
                            alert(data);
                            var href="{:U('register3',array('news'=>'error'))}";
                            href = href.replace("error",data);
                            window.location.href=href;
                        }

                    });
        });
    });
</script></title>
</head>
<body>
</body>
</html>